Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preset titles of duplicated templates and projects #4774

Merged

Conversation

solth
Copy link
Member

@solth solth commented Oct 19, 2021

Resolves #3789

@@ -210,6 +210,7 @@ public String duplicate(Integer itemId) {
try {
this.baseProject = ServiceManager.getProjectService().getById(itemId);
this.project = ServiceManager.getProjectService().duplicateProject(baseProject);
this.setSaveDisabled(false);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is possible to do without "this" then leave it out.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? Is that a coding guideline of us? We use "this" all the time to reference methods and properties of the current instance of a class (like the previous lines)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also find it unnecessary. I have also observed that you use this a lot, and I often find it superfluous. The IDE marks class fields very clearly so that this is no longer needed since color monitors came in use. I actually only use this when setting class fields in constructors and setters, where the parameter has the same name as the field to set. At this point it is also not necessary to call the setter. Why not:

template = ServiceManager.getTemplateService().duplicateTemplate(baseTemplate);
assignedProjects.clear();
assignedProjects.addAll(template.getProjects());
saveDisabled = false;

Copy link
Collaborator

@markusweigelt markusweigelt Oct 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Atm it is not a guideline, but from my perspective it is redundant because you can also access current methods and variables without "this" keyword. Except for example ambiguity between instance variables and method parameters and such cases.

It is true that it is already used very often. I do not know this massive use from other projects but ok then I will approve the review if the test is successful and take the topic with me to clarify it.

@@ -111,6 +111,7 @@ public String duplicate(Integer itemId) {
this.template = ServiceManager.getTemplateService().duplicateTemplate(baseTemplate);
this.assignedProjects.clear();
this.assignedProjects.addAll(template.getProjects());
this.setSaveDisabled(false);
return templateEditPath;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is possible to do without "this" then leave it out.

@Kathrin-Huber Kathrin-Huber merged commit c38954c into kitodo:master Oct 20, 2021
@solth solth deleted the preset-duplicate-titles branch October 21, 2021 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Preset name when duplicating projects and process templates
4 participants